<?php

class xtimeController {
	const message_file_path = '/tmp/xtime.json';

	/**
	 * Returns the latest message we received
	 * 
	 * @url GET /message
	 */
	public function getLatestMessage() {
		return json_decode(file_get_contents(self::message_file_path));
	}

	/**
	 *
	 * @url POST /message
	 * @url PUT  /message
	 */
	public function newMessage($data) {
		// Do some validation here
		file_put_contents(self::message_file_path, json_encode($data));

		return true;
	}
}
